package basic.demo.array;

public class ArrayStudy5 {

    /**
     * 输出斐波拉契数列 1 1 2 3 5 ... An = An-1 + An-2
     * 输入 n （n>=3)
     * 输出数列前n项值
     * 如 n = 4
     * 输出
     * 1 1 2 3
     *
     * @param args
     */

    public static void main(String[] args) {
        int n = 10;
        int[] a = new int[n];
        a[0] = 1;
        a[1] = 1;
        for (int i = 2; i < n; i++) {
            a[i] = a[i - 1] + a[i - 2];

        }
        for (int i = 0; i < n; i++) {
            System.out.print(a[i] + " ");
        }
    }


}



